import ALL from "../pages/ALL"
import WALLET from "../pages/WALLET"
import SCENE from "../pages/SCENE"

import Vue from "vue";
import VueRouter from "vue-router";
import Search from "../pages/Search";
import Drama from "../pages/Drama";
import Detail from "../pages/Detail";
import Choiceness from '../pages/Choiceness'
import Login from '../pages/Login'
import Minezhuce from '../pages/Mine'
import Router from 'vue-router'
import Reg from "../pages/Reg"
import Square from "../pages/Square"
import Calendar from "../pages/Calendar"
Vue.use(Router)

//安装vue-router
Vue.use(VueRouter);

// 1、路由配置（json数组）：path和component的对应关系

let routes = [
    {
        path: '/',
        component:Choiceness,
        // children: [
            // {
            //     path: 'jingxuan',
            //     component: Choicenesscenter
            // },
            // {
            //     path: 'musicju',
            //     component: musicju
            // }
        // ]
    },
    {path: '/Login',component:Login}, 
    {path: '/Minezhuce',component:Minezhuce}, 
    {
        path:"/Search",
        component:Search
    },
    {
        path:"/Drama",
        component:Drama
    },
    {
        path:"/Detail/:id",
        component:Detail
    },
    {
        path:"/Detail",
        component:Detail
    },
    {
        path:"/reg",
        component:Reg
    },
    {
        path:"/square",
        component:Square
    },
    {
        path:"/calendar",
        component:Calendar
    },
    {
        path: '/ALL', //路径
        component: ALL, //组件
    },

    {
        path: '/WALLET',
        component: WALLET,
        meta: { requiresAuth: true }
    },
    {
        path: '/SCENE',
        component: SCENE,
        meta: { requiresAuth: true }
    },
]


// 2、创建vueRouter对象
let router = new VueRouter({ //插件路由对象
    // routes:routes
    routes,
  });

  //全局前置守卫
//   router.beforeEach((to,from,next)=>{
//       if(to.path=="/shopcart"){
//           if(localStorage.getItem("name")){
//               next(true)
//           }
//           else{
//               next("/Login")
//           }
//       }
//       else{
//           next(true)
//       }
//   })
  
  //5.导出路由实例，让它去控制vue根
  export default router
